home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / kit / part02 < prev    next >
Encoding:
Text File  |  1991-12-19  |  45.0 KB  |  1,585 lines

  1. Newsgroups: comp.sources.unix
  2. From: ram@eiffel.com (Raphael Manfredi)
  3. Subject: v25i050: kit - the ultimate mailing kit, Part02/04
  4. Sender: sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: ram@eiffel.com (Raphael Manfredi)
  8. Posting-Number: Volume 25, Issue 50
  9. Archive-Name: kit/part02
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 2 (of 4)."
  18. # Contents:  UNSHAR.HDR config.h.SH des/main.c kit/kit.SH
  19. #   kit/mailkit.SH kit/unkit.SH man/kit.SH
  20. # Wrapped by vixie@cognition.pa.dec.com on Thu Dec 19 21:18:29 1991
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. if test -f 'UNSHAR.HDR' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'UNSHAR.HDR'\"
  24. else
  25. echo shar: Extracting \"'UNSHAR.HDR'\" \(4302 characters\)
  26. sed "s/^X//" >'UNSHAR.HDR' <<'END_OF_FILE'
  27. Return-Path: ram@eiffel.com
  28. Received: by cognition.pa.dec.com; id AA07451; Mon, 25 Nov 91 12:57:25 -0800
  29. Received: by inet-gw-1.pa.dec.com; id AA23335; Mon, 25 Nov 91 12:57:21 -0800
  30. Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay2.UU.NET with SMTP 
  31. X    (5.61/UUNET-internet-primary) id AA04155; Mon, 25 Nov 91 15:57:11 -0500
  32. Received: from eiffel.UUCP by uunet.uu.net with UUCP/RMAIL
  33. X    (queueing-rmail) id 155650.21663; Mon, 25 Nov 1991 15:56:50 EST
  34. Received: by eiffel.eiffel.com (4.0/SMI-4.0)
  35. X    id AA09846; Mon, 25 Nov 91 12:40:15 PST
  36. Date: Mon, 25 Nov 91 12:40:15 PST
  37. XFrom: ram@eiffel.com (Raphael)
  38. Message-Id: <9111252040.AA09846@eiffel.eiffel.com>
  39. To: vixie
  40. Subject: kit 2.0 package (Part 1/3)
  41. XX-Mailer: MAILAGENT [version 2.8 PL11]
  42. X
  43. Here is the answer to your request:
  44. X
  45. X    maildist vixie@Pa.dec.com kit 2.0
  46. X
  47. X
  48. This is a shar file. It will be simpler to unshar it if you own the Rich Salz's
  49. cshar package. If you do not have it, send me the following mail:
  50. X
  51. X    Subject: Command
  52. X    @PACK shar
  53. X    @SH maildist vixie@Pa.dec.com cshar 3.0
  54. X
  55. and you will get cshar as shell archives.
  56. X
  57. Detailed intructions can be obtained by:
  58. X
  59. X    Subject: Command
  60. X    @SH mailhelp vixie@Pa.dec.com
  61. X
  62. Unshar: Save this mail into a file, e.g. "foo1" and wait until
  63. X    you have received the 3 parts. Then, do "unshar -n foo*". If you
  64. X    do not own "unshar", edit the 3 files and remove the mail header
  65. X    by hand before feeding into sh.
  66. X
  67. X-- maildist speaking for ram
  68. X
  69. X
  70. Return-Path: ram@eiffel.com
  71. Received: by cognition.pa.dec.com; id AA07900; Mon, 25 Nov 91 13:08:01 -0800
  72. Received: by inet-gw-1.pa.dec.com; id AA24318; Mon, 25 Nov 91 13:07:57 -0800
  73. Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay1.UU.NET with SMTP 
  74. X    (5.61/UUNET-internet-primary) id AA25668; Mon, 25 Nov 91 16:07:38 -0500
  75. Received: from eiffel.UUCP by uunet.uu.net with UUCP/RMAIL
  76. X    (queueing-rmail) id 160633.24288; Mon, 25 Nov 1991 16:06:33 EST
  77. Received: by eiffel.eiffel.com (4.0/SMI-4.0)
  78. X    id AA09847; Mon, 25 Nov 91 12:40:18 PST
  79. Date: Mon, 25 Nov 91 12:40:18 PST
  80. XFrom: ram@eiffel.com (Raphael)
  81. Message-Id: <9111252040.AA09847@eiffel.eiffel.com>
  82. To: vixie
  83. Subject: kit 2.0 package (Part 2/3)
  84. XX-Mailer: MAILAGENT [version 2.8 PL11]
  85. X
  86. Here is the answer to your request:
  87. X
  88. X    maildist vixie@Pa.dec.com kit 2.0
  89. X
  90. X
  91. This is a shar file. It will be simpler to unshar it if you own the Rich Salz's
  92. cshar package. If you do not have it, send me the following mail:
  93. X
  94. X    Subject: Command
  95. X    @PACK shar
  96. X    @SH maildist vixie@Pa.dec.com cshar 3.0
  97. X
  98. and you will get cshar as shell archives.
  99. X
  100. Detailed intructions can be obtained by:
  101. X
  102. X    Subject: Command
  103. X    @SH mailhelp vixie@Pa.dec.com
  104. X
  105. Unshar: Save this mail into a file, e.g. "foo2" and wait until
  106. X    you have received the 3 parts. Then, do "unshar -n foo*". If you
  107. X    do not own "unshar", edit the 3 files and remove the mail header
  108. X    by hand before feeding into sh.
  109. X
  110. X-- maildist speaking for ram
  111. X
  112. X
  113. Return-Path: ram@eiffel.com
  114. Received: by cognition.pa.dec.com; id AA07407; Mon, 25 Nov 91 12:53:37 -0800
  115. Received: by inet-gw-1.pa.dec.com; id AA22997; Mon, 25 Nov 91 12:53:34 -0800
  116. Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay2.UU.NET with SMTP 
  117. X    (5.61/UUNET-internet-primary) id AA03531; Mon, 25 Nov 91 15:53:35 -0500
  118. Received: from eiffel.UUCP by uunet.uu.net with UUCP/RMAIL
  119. X    (queueing-rmail) id 155157.20607; Mon, 25 Nov 1991 15:51:57 EST
  120. Received: by eiffel.eiffel.com (4.0/SMI-4.0)
  121. X    id AA09848; Mon, 25 Nov 91 12:40:20 PST
  122. Date: Mon, 25 Nov 91 12:40:20 PST
  123. XFrom: ram@eiffel.com (Raphael)
  124. Message-Id: <9111252040.AA09848@eiffel.eiffel.com>
  125. To: vixie
  126. Subject: kit 2.0 package (Part 3/3)
  127. XX-Mailer: MAILAGENT [version 2.8 PL11]
  128. X
  129. Here is the answer to your request:
  130. X
  131. X    maildist vixie@Pa.dec.com kit 2.0
  132. X
  133. X
  134. This is a shar file. It will be simpler to unshar it if you own the Rich Salz's
  135. cshar package. If you do not have it, send me the following mail:
  136. X
  137. X    Subject: Command
  138. X    @PACK shar
  139. X    @SH maildist vixie@Pa.dec.com cshar 3.0
  140. X
  141. and you will get cshar as shell archives.
  142. X
  143. Detailed intructions can be obtained by:
  144. X
  145. X    Subject: Command
  146. X    @SH mailhelp vixie@Pa.dec.com
  147. X
  148. Unshar: Save this mail into a file, e.g. "foo3" and wait until
  149. X    you have received the 3 parts. Then, do "unshar -n foo*". If you
  150. X    do not own "unshar", edit the 3 files and remove the mail header
  151. X    by hand before feeding into sh.
  152. X
  153. X-- maildist speaking for ram
  154. X
  155. X
  156. END_OF_FILE
  157. if test 4302 -ne `wc -c <'UNSHAR.HDR'`; then
  158.     echo shar: \"'UNSHAR.HDR'\" unpacked with wrong size!
  159. fi
  160. # end of 'UNSHAR.HDR'
  161. fi
  162. if test -f 'config.h.SH' -a "${1}" != "-c" ; then 
  163.   echo shar: Will not clobber existing file \"'config.h.SH'\"
  164. else
  165. echo shar: Extracting \"'config.h.SH'\" \(4258 characters\)
  166. sed "s/^X//" >'config.h.SH' <<'END_OF_FILE'
  167. case $CONFIG in
  168. X'')
  169. X    if test ! -f config.sh; then
  170. X        ln ../config.sh . || \
  171. X        ln ../../config.sh . || \
  172. X        ln ../../../config.sh . || \
  173. X        (echo "Can't find config.sh."; exit 1)
  174. X    fi 2>/dev/null
  175. X    . ./config.sh
  176. X    ;;
  177. esac
  178. echo "Extracting config.h (with variable substitutions)"
  179. sed <<!GROK!THIS! >config.h -e 's!^#undef!/\*#define!'
  180. X/*
  181. X * This file was produced by running the config.h.SH script, which
  182. X * gets its values from config.sh, which is generally produced by
  183. X * running Configure.
  184. X *
  185. X * Feel free to modify any of this as the need arises.  Note, however,
  186. X * that running config.h.SH again will wipe out any changes you've made.
  187. X * For a more permanent change edit config.sh and rerun config.h.SH.
  188. X *
  189. X * \$Id: config.h.SH,v 2.0.1.5 91/11/25 15:48:49 ram Exp $
  190. X */
  191. X
  192. X#ifndef _config_h_
  193. X#define _config_h_
  194. X
  195. X/* BYTEORDER
  196. X *    This symbol hold the hexadecimal constant defined in byteorder,
  197. X *    i.e. 0x1234 or 0x4321, etc...
  198. X */
  199. X#define BYTEORDER 0x$byteorder    /* large digits for MSB */
  200. X
  201. X/* GETOPT:
  202. X *    This symbol, if defined, indicates that the getopt() routine exists.
  203. X */
  204. X#$d_getopt    GETOPT        /**/
  205. X
  206. X/* index:
  207. X *    This preprocessor symbol is defined, along with rindex, if the system
  208. X *    uses the strchr and strrchr routines instead.
  209. X */
  210. X#$d_index    index strchr    /**/
  211. X
  212. X/* MEMCPY:
  213. X *    This symbol, if defined, indicates that the memcpy routine is available
  214. X *    to copy blocks of memory. You should always use bcopy() instead of
  215. X *    memcpy() because bcopy is remaped to memcpy if necessary. This means
  216. X *    that a memcpy() routine must be provided in case MEMCPY is not defined
  217. X *    and no bcopy() is found.
  218. X */
  219. X#$d_memcpy    MEMCPY        /**/
  220. X
  221. X/* MEMSET:
  222. X *    This symbol, if defined, indicates that the memset routine is available
  223. X *    to set blocks of memory. You should always use bzero() instead of
  224. X *    memset() because bzero is remaped to memset if necessary. This means
  225. X *    that a memset() routine must be provided in case MEMSET is not defined
  226. X *    and no bzero() is found.
  227. X */
  228. X#$d_memset    MEMSET        /**/
  229. X
  230. X/* SIGNAL_T:
  231. X *    This symbol's value is either "void" or "int", corresponding to the
  232. X *    appropriate return type of a signal handler.  Thus, you can declare
  233. X *    a signal handler using "SIGNAL_T (*handler())()", and define the
  234. X *    handler using "SIGNAL_T handler(sig)".
  235. X */
  236. X#define SIGNAL_T $signal_t    /* Kept for backward compatibility */
  237. X
  238. X/* I_SYSIOCTL:
  239. X *    This symbol, if defined, indicates that <sys/ioctl.h> exists and should
  240. X *    be included. Otherwise, include <sgtty.h> or <termio.h>.
  241. X */
  242. X#$i_sysioctl    I_SYSIOCTL        /**/
  243. X
  244. X/* I_TERMIO:
  245. X *    This symbol, if defined, indicates that the program should include
  246. X *    <termio.h> rather than <sgtty.h>.  There are also differences in
  247. X *    the ioctl() calls that depend on the value of this symbol.
  248. X */
  249. X/* I_TERMIOS:
  250. X *    This symbol, if defined, indicates that the program should include
  251. X *    the POSIX termios.h rather than sgtty.h or termio.h.
  252. X *    There are also differences in the ioctl() calls that depend on the
  253. X *    value of this symbol.
  254. X */
  255. X/* I_SGTTY:
  256. X *    This symbol, if defined, indicates that the program should include
  257. X *    <sgtty.h> rather than <termio.h>.  There are also differences in
  258. X *    the ioctl() calls that depend on the value of this symbol.
  259. X */
  260. X#$i_termio    I_TERMIO        /**/
  261. X#$i_termios    I_TERMIOS        /**/
  262. X#$i_sgtty    I_SGTTY        /**/
  263. X
  264. X/* VOIDFLAGS
  265. X *    This symbol indicates how much support of the void type is given by this
  266. X *    compiler.  What various bits mean:
  267. X *
  268. X *        1 = supports declaration of void
  269. X *        2 = supports arrays of pointers to functions returning void
  270. X *        4 = supports comparisons between pointers to void functions and
  271. X *            addresses of void functions
  272. X *        8 = suports declaration of generic void pointers
  273. X *
  274. X *    The package designer should define VOIDUSED to indicate the requirements
  275. X *    of the package.  This can be done either by #defining VOIDUSED before
  276. X *    including config.h, or by defining defvoidused in Myinit.U.  If the
  277. X *    latter approach is taken, only those flags will be tested.  If the
  278. X *    level of void support necessary is not present, defines void to int.
  279. X */
  280. X#ifndef VOIDUSED
  281. X#define VOIDUSED $defvoidused
  282. X#endif
  283. X#define VOIDFLAGS $voidflags
  284. X#if (VOIDFLAGS & VOIDUSED) != VOIDUSED
  285. X#$define void int        /* is void to be avoided? */
  286. X#$define M_VOID            /* Xenix strikes again */
  287. X#endif
  288. X
  289. X#endif
  290. X!GROK!THIS!
  291. END_OF_FILE
  292. if test 4258 -ne `wc -c <'config.h.SH'`; then
  293.     echo shar: \"'config.h.SH'\" unpacked with wrong size!
  294. fi
  295. chmod +x 'config.h.SH'
  296. # end of 'config.h.SH'
  297. fi
  298. if test -f 'des/main.c' -a "${1}" != "-c" ; then 
  299.   echo shar: Will not clobber existing file \"'des/main.c'\"
  300. else
  301. echo shar: Extracting \"'des/main.c'\" \(4088 characters\)
  302. sed "s/^X//" >'des/main.c' <<'END_OF_FILE'
  303. X/* Encrypt/decrypt command compatible with Sun's "des" command */
  304. X/*
  305. X * $Id: main.c,v 2.0.1.1 91/04/01 15:40:10 ram Exp $
  306. X *
  307. X * $Log:    main.c,v $
  308. X * Revision 2.0.1.1  91/04/01  15:40:10  ram
  309. X * patch1: created
  310. X * 
  311. X */
  312. X
  313. X#include <stdio.h>
  314. X
  315. char iv[8];    /* Initial vector for CBC mode */
  316. int block;
  317. X
  318. main(argc,argv)
  319. int argc;
  320. char *argv[];
  321. X{
  322. X    int c,cnt,encrypt,decrypt,hexflag;
  323. X    register int i;
  324. X    char key[8],tkey1[20],tkey2[20],*akey,*getpass();
  325. X    extern char *optarg;
  326. X
  327. X    hexflag = block = encrypt = decrypt = 0;
  328. X    akey = NULL;
  329. X    while((c = getopt(argc,argv,"hedk:b")) != EOF){
  330. X        switch(c){
  331. X        case 'h':
  332. X            hexflag++;
  333. X            break;
  334. X        case 'e':
  335. X            encrypt++;
  336. X            break;
  337. X        case 'd':
  338. X            decrypt++;
  339. X            break;
  340. X        case 'k':
  341. X            akey = optarg;
  342. X            break;
  343. X        case 'b':
  344. X            block++;
  345. X            break;
  346. X        }
  347. X    }
  348. X    if(encrypt == 0 && decrypt == 0){
  349. X        fprintf(stderr,"Usage: des -e|-d [-h] [-k key]\n");
  350. X        exit(2);
  351. X    }
  352. X    if(akey == NULL){
  353. X        /* No key on command line, prompt for it */
  354. X        memset(tkey1,0,sizeof(tkey1));
  355. X        memset(tkey2,0,sizeof(tkey2));
  356. X        for(;;){
  357. X            akey = getpass("Enter key: ");
  358. X            strncpy(tkey1,akey,sizeof(tkey1));
  359. X            akey = getpass("Enter key again: ");
  360. X            strncpy(tkey2,akey,sizeof(tkey2));
  361. X            if(strncmp(tkey1,tkey2,sizeof(tkey1)) != 0){
  362. X                fprintf(stderr,"Key mistyped, try again\n");
  363. X            } else
  364. X                break;
  365. X        }
  366. X        akey = tkey1;
  367. X    }
  368. X    if(hexflag){
  369. X        for(i=0;i<16;i++){
  370. X            if(htoa(akey[i]) == -1){
  371. X                fprintf(stderr,"Non-hex character in key\n");
  372. X                exit(1);
  373. X            }
  374. X        }
  375. X        gethex(key,akey,8);
  376. X    } else {
  377. X        strncpy(key,akey,8);
  378. X        /* Set up key, determine parity bit */
  379. X        for(cnt = 0; cnt < 8; cnt++){
  380. X            c = 0;
  381. X            for(i=0;i<7;i++)
  382. X                if(key[cnt] & (1 << i))
  383. X                    c++;
  384. X            if((c & 1) == 0)
  385. X                key[cnt] |= 0x80;
  386. X            else
  387. X                key[cnt] &= ~0x80;
  388. X        }
  389. X    }
  390. X    /* Blot out original key */
  391. X    i = strlen(akey);
  392. X    i = (i < 8) ? i : 8;
  393. X    memset(akey,0,i);
  394. X
  395. X    desinit(0);
  396. X    setkey(key);
  397. X
  398. X    /* Initialize IV to all zeros */
  399. X    memset(iv,0,8);
  400. X
  401. X    if(encrypt){
  402. X        doencrypt();
  403. X    } else {
  404. X        dodecrypt();
  405. X    }
  406. X}
  407. X/* Encrypt standard input to standard output */
  408. doencrypt()
  409. X{
  410. X    char work[8],*cp,*cp1;
  411. X    int cnt,i;
  412. X
  413. X    for(;;){
  414. X        if((cnt = fread(work,1,8,stdin)) != 8){
  415. X            /* Put residual byte count in the last block.
  416. X             * Note that garbage is left in the other bytes,
  417. X             * if any; this is a feature, not a bug, since it'll
  418. X             * be stripped out at decrypt time.
  419. X             */
  420. X            work[7] = cnt;
  421. X        }
  422. X        if(!block){
  423. X            /* CBC mode; chain in last cipher word */
  424. X            cp = work;
  425. X            cp1 = iv;
  426. X            for(i=8; i!=0; i--)
  427. X                *cp++ ^= *cp1++;
  428. X        }
  429. X        endes(work);    /* Encrypt block */
  430. X        if(!block){    /* Save outgoing ciphertext for chain */
  431. X            memcpy(iv,work,8);
  432. X        }
  433. X        fwrite(work,1,8,stdout);
  434. X        if(cnt != 8)
  435. X            break;
  436. X    }
  437. X}
  438. dodecrypt()
  439. X{
  440. X    char work[8],nwork[8],ivtmp[8],*cp,*cp1;
  441. X    int cnt,i;
  442. X
  443. X
  444. X    cnt = fread(work,1,8,stdin);    /* Prime the pump */
  445. X    for(;;){
  446. X        if(!block){    /* Save incoming ciphertext for chain */
  447. X            memcpy(ivtmp,work,8);
  448. X        }
  449. X        dedes(work);
  450. X        if(!block){    /* Unchain block, save ciphertext for next */
  451. X            cp = work;
  452. X            cp1 = iv;
  453. X            for(i=8; i!=0; i--){
  454. X                *cp++ ^= *cp1++;
  455. X            }
  456. X            memcpy(iv,ivtmp,8);
  457. X        }
  458. X        /* Save buffer pending next read */
  459. X        memcpy(nwork,work,8);
  460. X        /* Try to read next block */
  461. X        cnt = fread(work,1,8,stdin);
  462. X        if(cnt != 8){    /* Can "only" be 0 if not 8 */
  463. X            /* Prev block was last one, write appropriate number
  464. X             * of bytes
  465. X             */
  466. X            cnt = nwork[7];
  467. X            if(cnt < 0 || cnt > 7){
  468. X                fprintf(stderr,"Corrupted file or wrong key\n");
  469. X            } else if(cnt != 0)
  470. X                fwrite(nwork,1,cnt,stdout);
  471. X            exit(0);
  472. X        } else {
  473. X            /* Now okay to write previous buffer */
  474. X            fwrite(nwork,1,8,stdout);
  475. X        }
  476. X
  477. X    }
  478. X}
  479. X/* Convert hex/ascii nybble to binary */
  480. int
  481. htoa(c)
  482. char c;
  483. X{
  484. X    if(c >= '0' && c <= '9')
  485. X        return c - '0';
  486. X    if(c >= 'a' && c <= 'f')
  487. X        return 10 + c - 'a';
  488. X    if(c >= 'A' && c <= 'F')
  489. X        return 10 + c - 'A';
  490. X    return -1;
  491. X}
  492. X/* Convert bytes from hex/ascii to binary */
  493. gethex(result,cp,cnt)
  494. register char *result;
  495. register char *cp;
  496. register int cnt;
  497. X{
  498. X    while(cnt-- != 0){
  499. X        *result = htoa(*cp++) << 4;
  500. X        *result++ |= htoa(*cp++);
  501. X    }
  502. X}
  503. X#ifdef    DEBUG
  504. put8(cp)
  505. register char *cp;
  506. X{
  507. X    int i;
  508. X
  509. X    for(i=0;i<8;i++){
  510. X        fprintf(stderr,"%02x ",*cp++ & 0xff);
  511. X    }
  512. X}
  513. X#endif
  514. X
  515. END_OF_FILE
  516. if test 4088 -ne `wc -c <'des/main.c'`; then
  517.     echo shar: \"'des/main.c'\" unpacked with wrong size!
  518. fi
  519. # end of 'des/main.c'
  520. fi
  521. if test -f 'kit/kit.SH' -a "${1}" != "-c" ; then 
  522.   echo shar: Will not clobber existing file \"'kit/kit.SH'\"
  523. else
  524. echo shar: Extracting \"'kit/kit.SH'\" \(8103 characters\)
  525. sed "s/^X//" >'kit/kit.SH' <<'END_OF_FILE'
  526. case $CONFIG in
  527. X'')
  528. X    if test ! -f config.sh; then
  529. X        ln ../config.sh . || \
  530. X        ln ../../config.sh . || \
  531. X        ln ../../../config.sh . || \
  532. X        (echo "Can't find config.sh."; exit 1)
  533. X    fi 2>/dev/null
  534. X    . config.sh
  535. X    ;;
  536. esac
  537. case "$0" in
  538. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  539. esac
  540. echo "Extracting kit/kit (with variable substitutions)"
  541. X$spitshell >kit <<!GROK!THIS!
  542. X$startsh
  543. X# @(#) converts to ascii && packages a whole directory
  544. X# @(#) (c) E. Mogenet April, 1990
  545. X# @(#) (c) R. Manfredi, 1990 1991
  546. X
  547. X# Which patch-level is it ?
  548. pl='$PATCHLEVEL'
  549. version='$VERSION'
  550. libdir='$privlib'
  551. X!GROK!THIS!
  552. X$spitshell >>kit <<'!NO!SUBS!'
  553. X
  554. X# $Id: kit.SH,v 2.0.1.6 91/12/08 14:55:06 ram Exp $
  555. X#
  556. X# $Log:    kit.SH,v $
  557. X# Revision 2.0.1.6  91/12/08  14:55:06  ram
  558. X# patch10: forgot to protect evaluation of variable in a test
  559. X# 
  560. X# Revision 2.0.1.5  91/11/25  15:50:59  ram
  561. X# patch9: added option -M which asks for minikit inclusion
  562. X# patch9: the subject given to mailkit was wrong unless -s was used
  563. X# 
  564. X# Revision 2.0.1.4  91/11/25  12:08:20  ram
  565. X# patch8: stamping of kit parts is now done by kit instead of mailkit
  566. X# patch8: new option -l to give recipient file list
  567. X# patch8: removed comments describing usage and done some clean-up
  568. X# 
  569. X# Revision 2.0.1.3  91/07/30  17:24:20  ram
  570. X# patch6: config.sh now carries the symbols defined in patchlevel.h
  571. X# 
  572. X# Revision 2.0.1.2  91/05/27  14:25:21  ram
  573. X# patch5: added options -d and -n
  574. X# patch5: usage is no longer printed by a function
  575. X# patch5: redirection with piping in eval may yield i/o error
  576. X# patch5: version number is no longer hardwired
  577. X# 
  578. X# Revision 2.0.1.1  91/04/01  15:48:26  ram
  579. X# patch1: new options -x, -k and -X for encryption facilities
  580. X# patch1: naming convention for files has been revised
  581. X# patch1: kit now traps interrupts for a graceful exit
  582. X# 
  583. X# Revision 2.0  91/02/19  15:49:53  ram
  584. X# Baseline for first official release.
  585. X# 
  586. X
  587. coding=btoa                    # Program used for coding
  588. mode="zag"                    # Mode is the 'A' part of the name
  589. code="ba"                    # Code is the 'B' part of the name
  590. mailkit=mailkit                # Mailing program to use with kit
  591. invoke=no                    # Do we have to invoke mailkit ?
  592. tmpfile=/tmp/Kds$$            # Temporary file
  593. tmpdir="."                    # Temporary directory used
  594. partname="Kit"                # Default part name used
  595. minikit=''                    # Do not include minikit
  596. mininame=''                    # File where minikit's name is stored
  597. instruct=''                    # Instrucutions for minikit usage
  598. X
  599. X# Mailkit options
  600. mailopt=""
  601. subject=""
  602. X
  603. X# DES options
  604. key=""
  605. desopt=""
  606. X
  607. X# Old Bourne shells do not have functions
  608. usage='
  609. echo "Usage: kit [-BEFHMVXefhpx] [-d dir] [-k key] [-m address] [-n basename]";
  610. echo " "" "" "" "" "" "" [-l file] [-s name] dirs | files";
  611. echo " "" -B : use btoa encoding (default).";
  612. echo " "" -E : edit instructions for part #0 (passed to mailkit).";
  613. echo " "" -F : feed instructions from stdin to part #0 (passed to mailkit).";
  614. echo " "" -H : use hex-encoding.";
  615. echo " "" -M : include minikit in the distribution.";
  616. echo " "" -V : print version and patch-level.";
  617. echo " "" -X : use Electronic Code Block DES encryption.";
  618. echo " "" -d : put temporary files in the specified directory.";
  619. echo " "" -e : edit instructions to add in each part (passed to mailkit).";
  620. echo " "" -f : feed instructions from stdin in each part (passed to mailkit).";
  621. echo " "" -h : to print this help message.";
  622. echo " "" -k : sets the key used for data encryption.";
  623. echo " "" -m : invoke mailkit to mail the parts.";
  624. echo " "" "" "" "" "" "" There may be as many -m as necessary.";
  625. echo " "" -l : file holding the recipient list (passed to mailkit).";
  626. echo " "" -n : set the basename of the generated parts (default is $partname).";
  627. echo " "" -p : preserve files sent (given to mailkit).";
  628. echo " "" -s : set kit name (given to mailkit).";
  629. echo " "" -x : use Cipher Block Chaining DES encryption (default).";
  630. exit 1
  631. X'
  632. X
  633. for i in $*
  634. do
  635. X    case $i in 
  636. X    -M) shift
  637. X        if test -f minikit; then
  638. X            if test -f MINIKIT; then
  639. X                minikit="mkit$$"
  640. X            else
  641. X                minikit='MINIKIT'
  642. X            fi
  643. X        else
  644. X            minikit='minikit'
  645. X        fi
  646. X        ;;
  647. X    -H) shift
  648. X        coding=hexencode
  649. X        code="hex"
  650. X        ;;
  651. X    -B) shift
  652. X        coding=btoa
  653. X        code="ba"
  654. X        ;;
  655. X    -E|-e|-F|-f|-p) mailopt="$mailopt $1"
  656. X        shift
  657. X        ;;
  658. X    -X) desopt="-b"
  659. X        mode="zec"
  660. X        shift
  661. X        ;;
  662. X    -d) tmpdir="$2"
  663. X        shift
  664. X        shift
  665. X        ;;
  666. X    -x) desopt=""
  667. X        mode="zcb"
  668. X        shift
  669. X        ;;
  670. X    -k) key=" -k $2"
  671. X        case "$mode" in
  672. X        zag) mode="zcb";;
  673. X        esac
  674. X        shift
  675. X        shift
  676. X        ;;
  677. X    -m) address="$address $2"
  678. X        invoke=yes
  679. X        shift
  680. X        shift
  681. X        ;;
  682. X    -l) mailopt="$mailopt -l $2"
  683. X        invoke=yes
  684. X        shift
  685. X        shift
  686. X        ;;
  687. X    -n) partname="$2"
  688. X        shift
  689. X        shift
  690. X        ;;
  691. X    -s) subject="$2"
  692. X        shift
  693. X        shift
  694. X        ;;
  695. X    -V) echo "kit $version PL$pl"
  696. X        exit 0
  697. X        ;;
  698. X    -h) eval $usage
  699. X        ;;
  700. X    -*) echo "unkown option $1"
  701. X        eval $usage
  702. X    esac
  703. done
  704. X
  705. X# At this stage, $1 should hold the name of a file or a directory
  706. if test "x$1" = x
  707. then
  708. X    eval $usage
  709. fi
  710. X
  711. rm -f $tmpdir/$partname??            # Make sure no parts already exist
  712. X
  713. X# If DES is to be performed, do it before ASCII coding
  714. case "$mode" in
  715. zag);;
  716. X*) desopt="$desopt -e"$key
  717. X    coding="des $desopt | "$coding;;
  718. esac
  719. X
  720. X# We have two encoding methods for binary datas:
  721. X# - hexencode: brute force (mogenix)
  722. X# - btoa: binary to ascii (ram)
  723. X#
  724. X# As we want to make kit-unkit encoding-independant, the following
  725. X# naming convention occurs for files split: names are A.B.* where:
  726. X#
  727. X#   - A is zag for uncrypted files
  728. X#   - A is zcb for DES encrypted files with CBC mode
  729. X#   - A is zec for DES encrypted files with ECB mode
  730. X# 
  731. X#   - B is hex for hex-encoded file
  732. X#   - B is ba for ASCII-encoded files
  733. X
  734. split_file=$mode.$code.        # Name used for spliting
  735. X
  736. X# In case we are interrupted
  737. trap "rm -f $tmpfile; cd $tmpdir; rm -f $partname?? ${split_file}* \
  738. X    $minikit $partname??.$$; echo >&2 'Aborted.'; exit 1" 1 2 3 15
  739. X
  740. X# We have to use a tmp file to avoid des prompting while tar is running
  741. tar cvf - $@ | compress -v > $tmpfile
  742. X
  743. cd $tmpdir
  744. X
  745. X# If minikit is to be used, copy the script from the library directory
  746. if test "$minikit"; then
  747. X    if test -r "$libdir/minikit"; then
  748. X        cp $libdir/minikit $minikit
  749. X        chmod +x $minikit
  750. X        # Name of the minikit program is passed along to unkit, so that the
  751. X        # script may be removed when unkit is ran...
  752. X        echo "$minikit" > zzz.minikit
  753. X        mininame=zzz.minikit
  754. X        # Prepare instructions for later
  755. X        instruct=">>
  756. X>> In case you do not have unkit, you may proceeed as follows:
  757. X>> - First run all the parts through unshar or sh. This will extract
  758. X>>   some temporary files, and among them a script called '$minikit'.
  759. X>> - Run the '$minikit' program, and the kit will be extracted for you.
  760. X>>   If the extraction is successful, all the temporary files previously
  761. X>>   extracted will be removed, including $minikit.
  762. X
  763. X"
  764. X    else
  765. X        echo >&2 "$0: cannot find minikit in $libdir"
  766. X        kill -15 $$
  767. X    fi
  768. fi
  769. X
  770. echo "Coding with $coding"
  771. X# Beware: 'eval $coding < $tmpfile' is not portable
  772. cat $tmpfile | eval $coding |
  773. split -600 - $split_file &&
  774. makekit -k100 -n $partname ${split_file}* $minikit $mininame &&
  775. rm ${split_file}* $minikit $mininame $tmpfile
  776. X
  777. case "$subject" in
  778. X'') subject=$1
  779. esac
  780. X
  781. X# Stamp the files, stating they are kit files and not shell archives
  782. set X $partname??
  783. shift
  784. nfiles=$#
  785. for file in $partname??
  786. do
  787. X    # Extract part number
  788. X    part=`expr $file : '[^0-9]*\(.*\)'`
  789. X    # Remove leading zero(s)
  790. X    part_num=`expr $part + 0`
  791. X    # Write kit header stamp message
  792. X    echo "Stamping kit $part_num..."
  793. X    genstamp=">> Generated by kit $version PL$pl on `date`"
  794. X    if test $nfiles -gt 1; then
  795. X        cat >$file.$$ <<EOH
  796. X>> This is a kit file (part #$part_num out of $nfiles). To unkit, save this message
  797. X>> into a file, e.g. foo$part, and wait until you have the $nfiles files.
  798. X>> Then, do "unkit foo*". To see what will be extracted, you may wish to
  799. X>> do "unkit -l foo*" before.
  800. X>>
  801. X$genstamp
  802. X$instruct
  803. XEOH
  804. X    else
  805. X        cat >$file.$$ <<EOH
  806. X>> This is a kit file. To unkit, save this message into a file, e.g. foo.
  807. X>> Then, do "unkit foo". To see what will be extracted, you may wish to
  808. X>> do "unkit -l foo" before.
  809. X>>
  810. X$genstamp
  811. X$instruct
  812. XEOH
  813. X    fi
  814. X    cat $file >>$file.$$
  815. X    mv $file.$$ $file
  816. done
  817. X
  818. X# If -m option used, invoke mailkit
  819. if test $invoke = yes; then
  820. X    $mailkit -n $partname $mailopt "$subject" $address
  821. fi
  822. X!NO!SUBS!
  823. chmod 755 kit
  824. X$eunicefix kit
  825. END_OF_FILE
  826. if test 8103 -ne `wc -c <'kit/kit.SH'`; then
  827.     echo shar: \"'kit/kit.SH'\" unpacked with wrong size!
  828. fi
  829. chmod +x 'kit/kit.SH'
  830. # end of 'kit/kit.SH'
  831. fi
  832. if test -f 'kit/mailkit.SH' -a "${1}" != "-c" ; then 
  833.   echo shar: Will not clobber existing file \"'kit/mailkit.SH'\"
  834. else
  835. echo shar: Extracting \"'kit/mailkit.SH'\" \(6605 characters\)
  836. sed "s/^X//" >'kit/mailkit.SH' <<'END_OF_FILE'
  837. case $CONFIG in
  838. X'')
  839. X    if test ! -f config.sh; then
  840. X        ln ../config.sh . || \
  841. X        ln ../../config.sh . || \
  842. X        ln ../../../config.sh . || \
  843. X        (echo "Can't find config.sh."; exit 1)
  844. X    fi 2>/dev/null
  845. X    . config.sh
  846. X    ;;
  847. esac
  848. case "$0" in
  849. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  850. esac
  851. echo "Extracting kit/mailkit (with variable substitutions)"
  852. X$spitshell >mailkit <<!GROK!THIS!
  853. X# @(#) Mailer for kit files
  854. X# @(#) (c) R. Manfredi, 1990 1991
  855. X
  856. X# $Id: mailkit.SH,v 2.0.1.4 91/12/08 14:55:22 ram Exp $
  857. X#
  858. X# $Log:    mailkit.SH,v $
  859. X# Revision 2.0.1.4  91/12/08  14:55:22  ram
  860. X# patch10: forgot to protect evaluation of variable in a test
  861. X# 
  862. X# Revision 2.0.1.3  91/11/25  12:09:23  ram
  863. X# patch8: stamping of kit parts is now done directly in kit
  864. X# patch8: added option -l to allow taking recipients from a file
  865. X# 
  866. X# Revision 2.0.1.2  91/07/30  17:26:26  ram
  867. X# patch6: config.sh now carries the symbols defined in patchlevel.h
  868. X# patch6: the subject line in mails now appears first for USG /bin/mail
  869. X# 
  870. X# Revision 2.0.1.1  91/05/27  14:28:37  ram
  871. X# patch5: added option -n
  872. X# patch5: usage is no longer printed by a function
  873. X# patch5: version number is no longer hardwired
  874. X# patch5: set -- was not supported everywhere; use set X and shift
  875. X# 
  876. X# Revision 2.0  91/02/19  15:49:57  ram
  877. X# Baseline for first official release.
  878. X# 
  879. X
  880. X# Define the mailer program
  881. mailer="$mailer"
  882. X
  883. X# Define the default editor
  884. editor=$defeditor
  885. X
  886. X# Which patch-level is it ?
  887. pl='$PATCHLEVEL'
  888. version='$VERSION'
  889. X!GROK!THIS!
  890. X$spitshell >>mailkit <<'!NO!SUBS!'
  891. X
  892. X# Flag used for -e/f and -E/F options
  893. edit=no
  894. added=no
  895. feed=no
  896. preserve=no
  897. recipients=''
  898. X
  899. X# Default part's name
  900. partname="Kit"
  901. X
  902. X# Old Bourne shells do not have functions
  903. usage='
  904. echo "Usage: mailkit [-EFVefhp] [-n base] [-l file] prog_name [address_list]";
  905. echo " "" -E : edit a message that will be sent as part #0";
  906. echo " "" -F : feed message from stdin and sent it as part #0";
  907. echo " "" -V : print version and patch-level";
  908. echo " "" -e : edit a message that will be added to every part";
  909. echo " "" -f : feed message from stdin to every part";
  910. echo " "" -h : to print this help message.";
  911. echo " "" -l : get recipients from a file (address_list is ignored).";
  912. echo " "" -n : set the basename of parts to be sent (default is $partname).";
  913. echo " "" -p : preserve files sent.";
  914. exit 1;
  915. X'
  916. X
  917. X# Argument parsing
  918. for i in $*
  919. do
  920. X    case $i in
  921. X    -V) echo "mailkit $version PL$pl"
  922. X        exit 0
  923. X        ;;
  924. X    -E) edit=yes
  925. X        added=no
  926. X        shift
  927. X        ;;
  928. X    -e) edit=yes
  929. X        added=yes
  930. X        shift
  931. X        ;;
  932. X    -h) eval $usage
  933. X        ;;
  934. X    -p) preserve=yes
  935. X        shift
  936. X        ;;
  937. X    -l) recipients="$2"
  938. X        shift
  939. X        shift
  940. X        ;;
  941. X    -n) partname="$2"
  942. X        shift
  943. X        shift
  944. X        ;;
  945. X    -f)    feed=yes
  946. X        added=yes
  947. X        shift
  948. X        ;;
  949. X    -F)    feed=yes
  950. X        added=no
  951. X        shift
  952. X        ;;
  953. X    -*) echo "unknown option $1"
  954. X        eval $usage
  955. X        ;;
  956. X    esac
  957. done
  958. X
  959. if test "x$1" = x; then
  960. X    echo >&2 "$0: missing program name"
  961. X    eval $usage
  962. fi
  963. X
  964. X# Save arguments before using set
  965. this_prog=$0
  966. prog_name=$1
  967. shift
  968. address=$@
  969. saved_address=$@
  970. X
  971. X# When a recipient file is provided, ignore the remaining of the command line
  972. if test "$recipients"; then
  973. X    if test -r "$recipients"; then
  974. X        # The format of the file is simple: a list of addresses, one per
  975. X        # line. Shell-style comments are allowed and multiple addresses on a
  976. X        # single line may be separated with spaces or commas.
  977. X        set X `<$recipients sed -n -e '/^[^#]/ {'    \
  978. X            -e 's/#.*//'    \
  979. X            -e 's/,/ /g'    \
  980. X            -e 's/\n/ /'    \
  981. X            -e 'p'            \
  982. X            -e '}'` $saved_address
  983. X        shift
  984. X        address=$@
  985. X    else
  986. X        echo >&2 "$this_prog: can't open $recipients"
  987. X        exit 1
  988. X    fi
  989. fi
  990. X
  991. if test "x$address" = x; then
  992. X    echo >&2 "$this_prog: missing recipient list"
  993. X    eval $usage
  994. fi
  995. X
  996. X# In case of editing, compute a temporary file name
  997. message=/tmp/MKt$$
  998. X# Temporary files used for building top message
  999. tmpmsg=/tmp/Nkt$$
  1000. topmsg=/tmp/Tkt$$
  1001. X
  1002. X# Set a trap in case we die abruptly
  1003. trap 'rm -f $message $tmpmsg $topmsg;
  1004. test $preserve = no && rm -f $partname??;
  1005. echo "Mailing aborted."
  1006. exit 1' 1 2 3 15
  1007. X
  1008. X# Count how many files there are
  1009. set X $partname??
  1010. shift
  1011. nfiles=$#
  1012. X
  1013. if test $edit = yes
  1014. then
  1015. X    # If editing was asked for, prepare the help message
  1016. X    cat >$message <<EOM
  1017. Please, enter your message here for the "$prog_name" kit.
  1018. Do not worry about this text, the 4 lines at the top will be removed.
  1019. XEOM
  1020. X    if test $added = yes
  1021. X    then
  1022. X        cat >>$message <<'EOM'
  1023. The message will be added at the top of each part.
  1024. XEOM
  1025. X    else
  1026. X        cat >>$message <<'EOM'
  1027. The message will be sent as part #0 and other parts will mention that.
  1028. XEOM
  1029. X    fi
  1030. X    cat >>$message <<'EOM'
  1031. X------------------------------------------------------------------------
  1032. XEOM
  1033. X    # Call the editor
  1034. X    $editor $message
  1035. X
  1036. X    # Now remove the 4 lines at the top
  1037. X    # Do not use tail +5, as this may not exist on every system
  1038. X    cp $message $tmpmsg
  1039. X    awk '{ nl += 1 }; nl > 4 { print }' <$tmpmsg >$message
  1040. X    rm -f $tmpmsg
  1041. X
  1042. X    # If message is empty, discard it.
  1043. X    if test ! -s $message
  1044. X    then
  1045. X        rm -f $message
  1046. X        edit=no
  1047. X    fi
  1048. elif test $feed = yes; then
  1049. X    edit=yes            # No differences from now on
  1050. X    cat > $message        # Feed from stdin
  1051. fi
  1052. X
  1053. X# Print recipient list
  1054. echo "Mailing \"$prog_name\" to the following recipient list:"
  1055. echo $address | tr ' ' '\012' | sed -e 's/^/    /'
  1056. X
  1057. for i in $partname??
  1058. do
  1059. X    # Extracts the part number (will it work on all systems ?)
  1060. X    # Note that this does not rely on the leader part of the name.
  1061. X    part=`expr $i : '[^0-9]*\(.*\)'`
  1062. X
  1063. X    # Remove leading zero(s).
  1064. X    # Is there a simpler way to do this ?
  1065. X    part_num=`expr ${part:-1} + 0`
  1066. X
  1067. X    # Protect against unexisting/unreadable files matching "$partname*"
  1068. X    if  test -f $i -a -r $i
  1069. X    then
  1070. X        echo Mailing $i \($prog_name\)
  1071. X        # System V /bin/mail does not recognize header correctly, unless the
  1072. X        # first line is a subject. Oh well...
  1073. X        cat > $topmsg <<EOH
  1074. Subject: $prog_name - kit #$part_num / $nfiles
  1075. To: $address
  1076. X
  1077. XEOH
  1078. X        # Has edit been requested ?
  1079. X        if test $edit = yes
  1080. X        then
  1081. X            if test $added = yes
  1082. X            then
  1083. X                # Add message to each part
  1084. X                cat $message >> $topmsg
  1085. X                # add a blank line
  1086. X                echo " " >> $topmsg
  1087. X            else
  1088. X                # Signals that there is a part #0
  1089. X                cat >> $topmsg <<EOM
  1090. X[ There is an instruction mail which is labeled: $prog_name - kit #0 / $nfiles ]
  1091. X
  1092. XEOM
  1093. X            fi
  1094. X        fi
  1095. X        cat $i >> $topmsg
  1096. X        $mailer $address < $topmsg
  1097. X        rm -f $topmsg
  1098. X    else
  1099. X        echo $this_prog: could not open $i >&2
  1100. X    fi
  1101. done
  1102. X
  1103. X# Is there a part #0 to send ?
  1104. if test $edit = yes -a $added = no
  1105. then
  1106. X    cat > $topmsg <<EOM
  1107. Subject: $prog_name - kit #0 / $nfiles
  1108. To: $address
  1109. X
  1110. X[ This is an instruction message for the $prog_name kit ]
  1111. X
  1112. XEOM
  1113. X    cat >>$topmsg <$message
  1114. X    echo Mailing instructions \($prog_name\)
  1115. X    $mailer $address < $topmsg
  1116. X    rm -f $topmsg
  1117. fi
  1118. X
  1119. X# Clean up
  1120. rm -f $message
  1121. test $preserve = no && rm -f $partname??
  1122. X!NO!SUBS!
  1123. chmod 755 mailkit
  1124. X$eunicefix mailkit
  1125. END_OF_FILE
  1126. if test 6605 -ne `wc -c <'kit/mailkit.SH'`; then
  1127.     echo shar: \"'kit/mailkit.SH'\" unpacked with wrong size!
  1128. fi
  1129. chmod +x 'kit/mailkit.SH'
  1130. # end of 'kit/mailkit.SH'
  1131. fi
  1132. if test -f 'kit/unkit.SH' -a "${1}" != "-c" ; then 
  1133.   echo shar: Will not clobber existing file \"'kit/unkit.SH'\"
  1134. else
  1135. echo shar: Extracting \"'kit/unkit.SH'\" \(4063 characters\)
  1136. sed "s/^X//" >'kit/unkit.SH' <<'END_OF_FILE'
  1137. case $CONFIG in
  1138. X'')
  1139. X    if test ! -f config.sh; then
  1140. X        ln ../config.sh . || \
  1141. X        ln ../../config.sh . || \
  1142. X        ln ../../../config.sh . || \
  1143. X        (echo "Can't find config.sh."; exit 1)
  1144. X    fi 2>/dev/null
  1145. X    . config.sh
  1146. X    ;;
  1147. esac
  1148. case "$0" in
  1149. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  1150. esac
  1151. echo "Extracting kit/unkit (with variable substitutions)"
  1152. X$spitshell >unkit <<!GROK!THIS!
  1153. X$startsh
  1154. X# @(#) unkit, reversal of kit
  1155. X# @(#) (c) E. Mogenet April 1990
  1156. X# @(#) (c) R. Manfredi, 1990 1991
  1157. X
  1158. X# $Id: unkit.SH,v 2.0.1.7 91/12/08 14:56:49 ram Exp $
  1159. X#
  1160. X# $Log:    unkit.SH,v $
  1161. X# Revision 2.0.1.7  91/12/08  14:56:49  ram
  1162. X# patch10: added space in the credit for Emmanuel Mogenet
  1163. X# 
  1164. X# Revision 2.0.1.6  91/11/25  15:52:14  ram
  1165. X# patch9: added a trap to clean-up things in case of interruption
  1166. X# patch9: now knows about minikit and zzz.minikit file
  1167. X# 
  1168. X# Revision 2.0.1.5  91/11/25  12:09:54  ram
  1169. X# patch8: random clean-up for consistency with other scripts
  1170. X# 
  1171. X# Revision 2.0.1.4  91/07/30  17:31:49  ram
  1172. X# patch6: config.sh now carries the symbols defined in patchlevel.h
  1173. X# patch6: not all the tar support -o option for ownership overwrite
  1174. X# patch6: the -v option for zcat did not make much sense
  1175. X# patch6: (last two reported by Richard Bielak <richieb@bony.com>)
  1176. X# 
  1177. X# Revision 2.0.1.3  91/05/27  14:29:22  ram
  1178. X# patch5: usage is no longer printed by a function
  1179. X# patch5: version number is no longer hardwired
  1180. X# 
  1181. X# Revision 2.0.1.2  91/04/30  13:34:11  ram
  1182. X# patch3: unkit now carries a built-in unshar
  1183. X# 
  1184. X# Revision 2.0.1.1  91/04/01  15:51:53  ram
  1185. X# patch1: unkit updated to deal with new naming conventions
  1186. X# patch1: for some reason, log messages from 1.0 had been kept
  1187. X# 
  1188. X# Revision 2.0  91/02/19  15:50:03  ram
  1189. X# Baseline for first official release.
  1190. X# 
  1191. X
  1192. X# Which patch-level is it ?
  1193. pl='$PATCHLEVEL'
  1194. version='$VERSION'
  1195. X
  1196. X!GROK!THIS!
  1197. X
  1198. case "$d_taropt_o" in
  1199. X"$define") opt='xvof';;
  1200. X*) opt='xvf';;
  1201. esac
  1202. echo "tar_opt='$opt'" >> unkit
  1203. X
  1204. X$spitshell >>unkit <<'!NO!SUBS!'
  1205. decoding=hexdecode            # Default decoding program
  1206. preserve=yes                # Preserve input files by default
  1207. X
  1208. X# In case we are interrupted, remove all the temporary files
  1209. trap 'test -f zzz.minikit && rm -f `cat zzz.minikit` zzz.minikit; \
  1210. X    rm -f z??.[hb][ea]*.??;  echo >&2 "Aborted."; exit 1' 1 2 3 15
  1211. X
  1212. X# Old Bourne shells do not have functions
  1213. usage='
  1214. echo "Usage: unkit [-hlprV] [file1 ... filen]";
  1215. echo " "" -h : give this help message.";
  1216. echo " "" -l : list the contents of a the kit files.";
  1217. echo " "" -p : preserve input files (default).";
  1218. echo " "" -r : remove input files if unshar succeeds.";
  1219. echo " "" -V : print current version and patch-level.";
  1220. exit 1
  1221. X'
  1222. X
  1223. X# Option parsing
  1224. for i in $*
  1225. do
  1226. X    case $i in
  1227. X    -p) preserve=yes
  1228. X        shift;;
  1229. X    -r) if test $tar_opt = xvof
  1230. X        then
  1231. X            preserve=no
  1232. X        fi
  1233. X        shift;;
  1234. X    -V) echo "unkit $version PL$pl"
  1235. X        exit 0;;
  1236. X    -h) eval $usage;;
  1237. X    -l) tar_opt=tvf
  1238. X        preserve=yes
  1239. X        shift;;
  1240. X    -*) echo "Unknown option $i"
  1241. X        eval $usage;;
  1242. X    esac
  1243. done
  1244. X
  1245. X# Test for unshar -- we have our own built-in unshar, but the
  1246. X# unshar that comes with cshar is smarter in case of errors and
  1247. X# much more reliable.
  1248. X
  1249. X# Use a sub-shell to avoid messages like "sh: unshar not found".
  1250. X# The "$a" variable is the parameter set by 'eval' (or empty if none).
  1251. if (unshar -n /dev/null) >/dev/null 2>&1
  1252. then
  1253. X    unshar_cmd='unshar -n $a'
  1254. else
  1255. X    # Our built-in unshar may not give a meaningful exit status
  1256. X    unshar_cmd='sed -n -e "/^#![     ]*\/bin\/sh/,\$p" $a | /bin/sh'
  1257. fi
  1258. X
  1259. X# If no file name is given, process the standard input
  1260. if test $# -eq 0
  1261. then
  1262. X    eval $unshar_cmd
  1263. else
  1264. X    for i
  1265. X    do
  1266. X        # The command expects "$a" to be the parameter
  1267. X        eval "a=$i; $unshar_cmd"    &&
  1268. X        (test $preserve = no && rm $i)
  1269. X    done
  1270. fi
  1271. X
  1272. X# Now check for file names to find how to decode
  1273. if test -f z[ace][gbc].ba.aa
  1274. then
  1275. X    decoding=atob
  1276. fi
  1277. if test -f zcb.*.aa
  1278. then
  1279. X    decoding=$decoding" | des -d"
  1280. elif test -f zec.*.aa
  1281. then
  1282. X    decoding=$decoding" | des -d -b"
  1283. fi
  1284. X
  1285. echo "Decoding with $decoding"
  1286. X
  1287. cat `ls z??.[hb][ea]*.??` |
  1288. eval $decoding        |
  1289. zcat                |
  1290. tar $tar_opt -
  1291. X
  1292. test -f zzz.minikit && rm -f `cat zzz.minikit` zzz.minikit
  1293. rm -f z??.[hb][ea]*.??
  1294. X!NO!SUBS!
  1295. chmod 755 unkit
  1296. X$eunicefix unkit
  1297. END_OF_FILE
  1298. if test 4063 -ne `wc -c <'kit/unkit.SH'`; then
  1299.     echo shar: \"'kit/unkit.SH'\" unpacked with wrong size!
  1300. fi
  1301. chmod +x 'kit/unkit.SH'
  1302. # end of 'kit/unkit.SH'
  1303. fi
  1304. if test -f 'man/kit.SH' -a "${1}" != "-c" ; then 
  1305.   echo shar: Will not clobber existing file \"'man/kit.SH'\"
  1306. else
  1307. echo shar: Extracting \"'man/kit.SH'\" \(9636 characters\)
  1308. sed "s/^X//" >'man/kit.SH' <<'END_OF_FILE'
  1309. case $CONFIG in
  1310. X'')
  1311. X    if test ! -f config.sh; then
  1312. X    ln ../config.sh . || \
  1313. X    ln ../../config.sh . || \
  1314. X    ln ../../../config.sh . || \
  1315. X    (echo "Can't find config.sh."; exit 1)
  1316. X    fi 2>/dev/null
  1317. X    . config.sh
  1318. X    ;;
  1319. esac
  1320. case "$0" in
  1321. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  1322. esac
  1323. echo "Extracting man/kit.$manext (with variable substitutions)"
  1324. X$rm -f kit.$manext
  1325. X$spitshell >kit.$manext <<!GROK!THIS!
  1326. X.TH KIT $manext ram
  1327. X''' @(#) Manual page for mailing kit -- (c) ram July 1990
  1328. X'''
  1329. X''' $Id: kit.SH,v 2.0.1.5 91/11/25 15:53:01 ram Exp $
  1330. X'''
  1331. X''' $Log:    kit.SH,v $
  1332. X''' Revision 2.0.1.5  91/11/25  15:53:01  ram
  1333. X''' patch9: added kit's -M option to include minikit
  1334. X''' patch9: documents the tar -o possible problem
  1335. X''' 
  1336. X''' Revision 2.0.1.4  91/11/25  12:10:23  ram
  1337. X''' patch8: documents new -l option for kit and mailkit
  1338. X''' 
  1339. X''' Revision 2.0.1.3  91/05/27  14:32:48  ram
  1340. X''' patch5: search for config.sh is now silent
  1341. X''' patch5: documented new options -d and -n for kit
  1342. X''' patch5: new option -n for mailkit
  1343. X''' patch5: the 'kit .' bug has now a workaround thanks to -d
  1344. X''' patch5: new example to show usage of -d and -n
  1345. X''' 
  1346. X''' Revision 2.0.1.2  91/04/30  13:38:47  ram
  1347. X''' patch3: fixed some English mistakes/misspellings
  1348. X''' patch3: unshar is no longer needed to unkit (built-in)
  1349. X''' patch3: the NOTE section has been revised
  1350. X''' 
  1351. X''' Revision 2.0.1.1  91/04/01  15:52:58  ram
  1352. X''' patch1: documented the new kit options -x, -k and -X
  1353. X''' patch1: new naming conventions for split files are described
  1354. X''' 
  1355. X''' Revision 2.0  91/02/19  15:50:28  ram
  1356. X''' Baseline for first official release.
  1357. X''' 
  1358. X'''
  1359. X.SH NAME
  1360. kit, mailkit, unkit \- the ultimate mailing tools
  1361. X.SH SYNOPSIS
  1362. X\fBkit\fR [ \fB\-EFHMBVXefhpx\fR ] [ \fB\-k\fI key\fR]
  1363. X[ \fB\-d\fI dir\fR ] [ \fB\-m\fI address\fR ] [ \fB\-n\fI basename\fR ]
  1364. X[ \fB\-l\fI file\fR ] [ \fB\-s\fI name\fR ] \fIdirectories\fR | \fIfiles\fR
  1365. X.br
  1366. X\fBmailkit\fR [ \fB\-EFVefhp\fR ] [ \fB\-l\fI file\fR ]
  1367. X[ \fB\-n\fI partname\fR ] \fItitle\fR [ \fIaddress(es)\fR ]
  1368. X.br
  1369. X\fBunkit\fR [ \fB\-hlprV\fR ] [ \fIfiles\fR ]
  1370. X.SH DESCRIPTION
  1371. X\fIKit\fR is the ultimate mailing tool. It enables you to mail
  1372. data without any consideration of possible escape sequences or
  1373. control characters.
  1374. Given a file name or a directory, it builds a single file using
  1375. X\fItar\fR(1) and \fIcompress\fR(1). Then this file is hex-encoded
  1376. X(option \fB\-H\fR) or ASCII-encoded with \fIbtoa\fR(1)
  1377. X(option \fB\-B\fR, which is used by default) before being shell-archived
  1378. by \fImakekit\fR(1).
  1379. X\fIKit\fR produces files that match "Kit*" regular expression.
  1380. This default base name can be changed thanks to \fB\-n\fR option.
  1381. On invocation, it removes all previously existing "Kit*" files.
  1382. With \fB\-m\fR option, it is possible to give one mail address, and
  1383. X\fIkit\fR will invoke \fImailkit\fR to send the archive. There may be
  1384. as many \fB\-m\fR options as needed (to send the same archive to more
  1385. than a single person).
  1386. If there are a lot of recipients, you may want to store them in a file
  1387. and use the \fB\-l\fR option to tell \fIkit\fR where the recipient file
  1388. is located.
  1389. X.PP
  1390. The \fB\-E\fR, \fB\-F\fR, \fB\-e\fR, \fB\-f\fR and \fB\-p\fR options are
  1391. passed on to \fImailkit\fR, so
  1392. if no \fB\-m\fR option is used, they will be ignored. When sending
  1393. files with \fB\-m\fR, the subject of the message holds the name of
  1394. the first file given in the command line (supposed to be the name
  1395. of the kit). It is possible to overwrite this default by using the
  1396. X\fB\-s\fR option.
  1397. X.PP
  1398. If you want to send sensible data, it is possible to encrypt them using
  1399. a public-domain implementation of Data Encryption Standard (DES).
  1400. The \fB\-x\fR option will use the Cipher Block Chaining mode (default),
  1401. while \fB\-X\fR requests the Electronic Code Book mode. If you do not
  1402. specify the encryption key with \fB\-k\fR, \fIdes\fR(1) will prompt you
  1403. for one. If you use the \fB\-k\fR option, \fB\-x\fR is assumed.
  1404. X.PP
  1405. It may happen that there are no write permissions in the directory
  1406. where the root directory to be kitted lies. The \fB-d\fR option enables
  1407. you to specify another directory, where all the temporary files will be
  1408. stored. If you use something like \fI/tmp\fR, you must be careful to use
  1409. X\fB\-n\fR to change the base name used (in case someone else is doing
  1410. the same thing, otherwise files may get mangled).
  1411. X.PP
  1412. When you send a kit to someone which may not have \fIkit\fR, the \fB\-M\fR
  1413. option may be used to include a \fIminikit\fR script, which is a minimal
  1414. set of commands to unkit an unencrypted ASCII-encoded kit. The overhead is
  1415. small (around 4K) and some instructions are provided in the header of every
  1416. kit part. The minikit is usually called \fIminikit\fR, but should you
  1417. already have a file with that name in your distribution, it will be renamed
  1418. X\fIMINIKIT\fR. If by chance (!) you named one of your files MINIKIT, then
  1419. a unique name of the form \fImkitXXXXX\fR will be generated (XXXXX stands
  1420. for the PID of the \fIkit\fR process).
  1421. X.PP
  1422. X\fIMailkit\fR takes "Kit*" files and sends them to a list of addresses.
  1423. The \fB\-n\fR option can be used to change that base name, if necessary.
  1424. XEach message sent corresponds to one part and has its \`Subject:'
  1425. field set to the number of this part with the \fItitle\fR given, and you
  1426. also have the total number of parts, so that missing parts can easily
  1427. be located.
  1428. X.PP
  1429. The options \fB\-E\fR and \fB\-e\fR from \fImailkit\fR enable you to give
  1430. the recipient some instructions. They both call an editor. At the
  1431. top of the file edited, there is a little message, which
  1432. will (of course) be stripped from the text you enter, so do not
  1433. remove it or your own message will be cut instead. With \fB\-E\fR,
  1434. the message will be sent in an extra part (#0), while with \fB\-e\fR
  1435. it will be included in each part. Empty messages will be ignored.
  1436. X.PP
  1437. When \fImailkit\fR is given a \fB\-l\fR option, it takes the file name
  1438. as a file whith recipients addresses in it and adds the optional addresses that
  1439. may be given on the command line. Addresses in the recipient file are
  1440. separated with spaces, commas or new lines. Shell-style comments starting with
  1441. a pound sign (#) are allowed.
  1442. X.PP
  1443. Options \fB\-F\fR and \fB\-f\fR are very similar, but take their
  1444. input from stdin (standard input) instead of calling an editor.
  1445. Option \fB\-p\fR asks \fImailkit\fR for preserving mailed files. They
  1446. are removed by default.
  1447. X.PP
  1448. X\fIUnkit\fR is used to restore the original files. The argument is
  1449. a list of archive files (or mail files, as \fIunshar\fR(1), which
  1450. is called by \fIunkit\fR, can deal with mail headers).
  1451. Input files are not removed unless option \fB\-r\fR is given. By default,
  1452. option \fB\-p\fR is used to preserve the input file(s).
  1453. If no file name is given to \fIunkit\fR, the standard input is processed.
  1454. This is useful to process messages directly from a mail user agent.
  1455. X.PP
  1456. If you want to know what \fIunkit\fR will create without actually
  1457. doing it, use the \fB\-l\fR option. With this option, \fB\-r\fR is
  1458. ignored.
  1459. X.PP
  1460. XFor all of these commands, option \fB\-V\fR prints the version
  1461. number with the current patch level and exits, while \fB\-h\fR gives
  1462. a little help message with the syntax and the meaning of the options.
  1463. X.SH FILES
  1464. X.PD 0
  1465. X.TP 20
  1466. Kit*
  1467. files generated by \fIkit\fR
  1468. X.TP
  1469. X{zag,zcb,zec}.hex.*
  1470. temporary files used by \fIkit\fR and \fIunkit\fR for datas which
  1471. are hex-encoded.
  1472. X.TP
  1473. X{zag,zcb,zec}.ba.*
  1474. temporary files used by \fIkit\fR and \fIunkit\fR for datas which
  1475. are ASCII-encoded.
  1476. X.TP
  1477. zag*
  1478. non encrypted files.
  1479. X.TP
  1480. zcb*
  1481. data encrypted using CBC mode.
  1482. X.TP
  1483. zec
  1484. data encrypted using ECB mode.
  1485. X.TP
  1486. zzz.minikit
  1487. file holding the name of the provided minikit script.
  1488. X.TP
  1489. X$privlib/minikit
  1490. the script which may be used to unkit a distribution when the kit
  1491. package is not available.
  1492. X.PD
  1493. X.SH NOTE
  1494. X.PP
  1495. In order to use kit, you need to install \fBcshar\fR in your
  1496. PATH (programs needed are \fIshar\fR, \fImakekit\fR).
  1497. Moreover, \fIhexdecode\fR, \fIhexencode\fR, \fIatob\fR and \fIbtoa\fR
  1498. must be installed and \fIcompress\fR must be available.
  1499. If any of these is missing, this mailing kit is useless.
  1500. X.PP
  1501. X.I Unkit
  1502. has its own \fIunshar\fR built-in, but it will not be used if
  1503. X\fIunshar\fR is installed, because it is really simple-minded and
  1504. not smart at all in case of errors. However, this is useful if
  1505. you do not have \fBcshar\fR, but still want to use \fIunkit\fR.
  1506. X.SH EXAMPLES
  1507. X.PP
  1508. To mail \fIram@educ.emse.fr\fR a directory called XLOCK and all what it may
  1509. hold, do:
  1510. X.sp
  1511. X.in +5
  1512. X.B kit XLOCK
  1513. X.br
  1514. X.B mailkit XLOCK ram@educ.emse.fr
  1515. X.in -5
  1516. X.sp
  1517. X\fIKit\fR will produce files Kit*, and mailkit will send them.
  1518. Or, to do it all in one:
  1519. X.sp
  1520. X.in +5
  1521. X.B kit \-m ram@educ.emse.fr XLOCK
  1522. X.in -5
  1523. X.sp
  1524. If you have no write permissions in the current directory, you can
  1525. specify an alternate directory for temporary files:
  1526. X.sp
  1527. X.in +5
  1528. X\fBkit \-m ram@eiffel.com \-d /tmp \-n mykit XLOCK\fR
  1529. X.in -5
  1530. X.sp
  1531. To unkit, save the mail messages in files called, e.g. xlock.01 (for
  1532. part 01), xlock.02 (for part 02) and so on.
  1533. Then do:
  1534. X.sp
  1535. X.in +5
  1536. X.B unkit xlock*
  1537. X.in -5
  1538. X.sp
  1539. XEven if it succeeds, files xlock* will not be removed.
  1540. X.SH BUGS
  1541. Try "kit .": it is harmless (well, I hope !), and you will quickly
  1542. understand the problem. The solution is to use the \fB\-d\fR option.
  1543. X.PP
  1544. If you use the
  1545. X.B \-r
  1546. option in
  1547. X.I unkit
  1548. and one or more kit parts are missing, all the files will be lost.
  1549. So use it with care...
  1550. X.PP
  1551. Some systems cannot extract tar archives with overwriting of ownership
  1552. informations (usually this is done with tar option -o).
  1553. X.SH "SEE ALSO"
  1554. atob($manext), btoa($manext), cshar(1), makekit(1).
  1555. X.SH AUTHOR
  1556. Raphael Manfredi <ram@eiffel.com>.
  1557. X
  1558. X\fIKit\fR was developed at the Ecole des Mines, Saint-Etienne,
  1559. XFrance.
  1560. X!GROK!THIS!
  1561. chmod 444 kit.$manext
  1562. END_OF_FILE
  1563. if test 9636 -ne `wc -c <'man/kit.SH'`; then
  1564.     echo shar: \"'man/kit.SH'\" unpacked with wrong size!
  1565. fi
  1566. # end of 'man/kit.SH'
  1567. fi
  1568. echo shar: End of archive 2 \(of 4\).
  1569. cp /dev/null ark2isdone
  1570. MISSING=""
  1571. for I in 1 2 3 4 ; do
  1572.     if test ! -f ark${I}isdone ; then
  1573.     MISSING="${MISSING} ${I}"
  1574.     fi
  1575. done
  1576. if test "${MISSING}" = "" ; then
  1577.     echo You have unpacked all 4 archives.
  1578.     rm -f ark[1-9]isdone
  1579. else
  1580.     echo You still need to unpack the following archives:
  1581.     echo "        " ${MISSING}
  1582. fi
  1583. ##  End of shell archive.
  1584. exit 0
  1585.